<?php

namespace App\Models\Cache;

/**
 * 项目缓存key
 * 注意：
 *   1.规范参看：
 *   2.本文件只保留解释注释，key-value对照参看：
 * Class CacheKey
 * @package App\Models\Cache
 */
class CacheKey
{
    // 登录
    public const USER_LOGIN_STATUS = 'string:login:status:{$platform}_{$token}'; // 登录态
    public const USER_LOGIN_METHOD = 'string:login:method:{$user_id}'; // 登录方式

    // 游客
    public const OAUTH_TOURIST = 'hash:tourist:oauth:{$token}'; // 第三方登录后，授权信息记录在游客上
    public const TOURIST_TOKEN_SNAPSHOT = 'string:tourist:snapshot:{$tourist_id}'; // 游客ID和token对照，key是游客ID
    public const UUID_TOURIST_SNAPSHOT = 'string:tourist:snapshot:{$uuid}'; // 游客ID和token对照，key是UUID
    public const TOKEN_TOURIST_SNAPSHOT = 'string:tourist:snapshot:{$token}'; // 游客ID和token对照，key是token

    // 短信
    public const SMS_PHONE_TEMPLATE = 'string:sms:{$phone}_{$code}_{$template}'; // 发送短信
    public const SMS_PHONE_ALREADY_SEND = 'string:sms:verify:{$phone}_{$template}'; // 短信重复发送校验
    public const SMS_SEND_TRY_COUNT = 'string:sms:try_count:{$phone}_{$template}'; // 发送成功，记录一下一分钟 总发送次数，超过 5次 提示：不要频繁发送

    // 计数
    public const COUNTER_ARTICLE = 'hash:counter:article:{$article_id}'; // 文章计数
    public const COUNTER_NOTE = 'hash:counter:note:{$note_id}'; // 笔记计数
    public const COUNTER_COMMENT = 'hash:counter:comment:{$comment_id}'; // 评论计数
    public const COUNTER_REPLY = 'hash:counter:reply:{$reply_id}'; // 回复计数
    public const COUNTER_DYNAMIC = 'hash:counter:dynamic:{$dynamic_id}'; // 动态计数
    public const COUNTER_USER = 'hash:counter:user:{$user_id}'; // 用户计数
    public const COUNTER_USER_ARTICLE = 'hash:counter:user_article:{$user_id}_{$article_id}'; // 用户对于文章的计数
    public const COUNTER_TOPIC = 'hash:counter:topic:{$topic_id}'; // 话题计数
    public const COUNTER_COLLECT_PACKAGE = 'hash:counter:package:{$package_id}';    //收藏夹统计
    public const COUNTER_USER_OWN_ARTICLE = 'hash:counter:user_own_article:{$user_id}_{$article_id}'; //用户原创文章计数

    // 点赞
    public const LIKE_USER_TARGET = 'string:like:{$user_id}_{$target_id}'; // 点赞
    public const CANCEL_LIKE_USER_TARGET = 'string:like:cancel:{$user_id}_{$target_id}'; // 取消点赞

    // 收藏
    public const COLLECT_USER_TARGET = 'string:collect:{$user_id}_{$target_id}_{$package_id}'; // 收藏
    public const CANCEL_COLLECT_USER_TARGET = 'string:collect:cancel:{$user_id}_{$target_id}_{$package_id}'; // 取消收藏

    // 用户推荐
    public const USER_RECOMMEND_TARGET = 'string:user_recommend:{$user_id}_{$target_id}'; // 用户推荐
    public const CANCEL_USER_RECOMMEND_TARGET = 'string:user_recommend:cancel:{$user_id}_{$target_id}'; // 用户取消推荐

    //话题
    public const TOPIC_USER_ATTENTION = 'string:topic:{$user_id}_{$topic_id}'; // 关注话题
    public const TOPIC_CANCEL_USER_ATTENTION = 'string:topic:cancel:{$user_id}_{$topic_id}'; // 取消关注话题
    public const TOPIC_DETAIL_TARGET_ID = 'string:topic:detail:{$topic_id}'; // 获取话题详情时，将【热门】【置顶】【关注】的话题内容ID，以逗号分隔存入缓存

    // 一键收藏
    public const ONE_CLICK_COLLECT_SPIDER = 'hash:spider_article:{$url}'; // 一键收藏文章相关信息入缓存
    public const ONE_CLICK_COLLECT_USER_SAVE = 'string:one_click_collect_save:{$user_id}_{$url}'; // 防止重复点击
    public const ONE_CLICK_COLLECT_REDIRECT_MAP = 'hash:one_click_collect:redirect_map:{$url}';

    // 业务锁
    public const LOCK_DYNAMIC_CREATE = 'string:lock:dynamic:{$target_id}_{$user_id}'; // 新增动态

    // 点赞消息
    public const MESSAGE_SEND_LIKE = 'string:send_like:{$sender_id}_{$receive_id}_{$target_id}'; // 发送点赞消息
    public const MESSAGE_RECEIVE_LIKE = 'string:receive_like:{$sender_id}_{$receive_id}_{$target_id}'; // 收到的点赞消息

    // 评论消息
    public const MESSAGE_SEND_COMMENT = 'string:send_comment:{$sender_id}_{$receive_id}_{$target_id}'; // 发出评论消息
    public const MESSAGE_RECEIVE_COMMENT = 'string:receive_comment:{$sender_id}_{$receive_id}_{$target_id}'; // 收到的评论消息

}
